<template>
  <div class="expertList-root" v-loading="loading">
    <div class="expert-row" v-for="(item,index) in experts" :key="index">
      <div class="expert-item">
        <div class="expert-item-label">鉴定专家：</div>
        <div class="expert-item-value">
          <el-button @click="expertDetail(item.userId)" size="mini" type="text">{{ item.nickName }}</el-button>
        </div>
      </div>
      <div class="expert-item">
        <div class="expert-item-label">鉴定时间：</div>
        <el-tooltip effect="light" :content="item.authenticateTime" placement="top">
          <div class="expert-item-value">{{ item.authenticateTime }}</div>
        </el-tooltip>
      </div>
      <div class="expert-item">
        <div class="expert-item-label">鉴定名称：</div>
        <el-tooltip effect="light" :content="item.name" placement="top">
          <div class="expert-item-value"> {{ item.name }}</div>
        </el-tooltip>

      </div>
      <div class="expert-item">
        <div class="expert-item-label">鉴定学名：</div>
        <el-tooltip effect="light" :content="item.scientificName" placement="top">
          <div class="expert-item-value">{{ item.scientificName }}</div>
        </el-tooltip>
      </div>
      <div class="expert-item">
        <div class="expert-item-label" style="flex-basis: 3em">科名：</div>
        <el-tooltip effect="light" :content="item.familyName" placement="top">
          <div class="expert-item-value">{{ item.familyName }}</div>
        </el-tooltip>
      </div>
      <div class="expert-item">
        <div class="expert-item-label" style="flex-basis: 3em">属名：</div>
        <el-tooltip effect="light" :content="item.categoryName" placement="top">
          <div class="expert-item-value">{{ item.categoryName }}</div>
        </el-tooltip>
      </div>
    </div>
  </div>
</template>

<script>
import { reactive, toRefs, onMounted, ref, watch, computed } from '@vue/composition-api'
import { authenticateList } from '@/api/industry/gpm'

export default {
  name: 'expertList',
  props: {
    cltId: {
      type: [String, Number],
      default: null
    }
  },
  setup(props, content) {
    let data = reactive({
      experts: [],
      loading: false
    })
    watch(() => props.cltId, () => {
      loadData()
    })
    const loadData = async() => {
      try {
        if (props.cltId == null) {
          return
        }
        data.loading = true
        let response = await authenticateList(props.cltId)
        data.experts = response.data
      } finally {
        data.loading = false
      }
    }
    const expertDetail = (id) => {
      content.emit('expertDetail', id)
    }
    onMounted(() => {
      loadData()
    })

    return { ...toRefs(data), expertDetail }
  }
}
</script>

<style scoped lang="scss">
.expertList-root {
  height: 100%;
  width: 100%;
  padding: 5px 10px;

  .expert-row {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;

    .expert-item {
      flex: 1 1;
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: flex-end;

      .expert-item-label {
        flex: 0 0 5em;
      }

      .expert-item-value {
        width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }

}
</style>
<style lang="scss">
.expertList-root {
  .el-button.el-button--text.el-button--mini {
    padding: 0;
  }
}

</style>
